 package cn.com.code;
 
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
 public class MyDecoder extends CumulativeProtocolDecoder
 {
   protected boolean doDecode(IoSession arg0, IoBuffer arg1, ProtocolDecoderOutput arg2)
     throws Exception
   {
	     if ( arg1.limit() > 0 )
	     {
	       byte[] array = new byte[arg1.limit()];
	 
	       for (int i = 0; i < arg1.limit(); ++i ) 
	       {
	         array[i] = arg1.get();
	       }
	       arg2.write(array);
	       return true;
	     }
	     return false;
   }
 }

